package threading;

public class ThreadDemo7 {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
                try {
                    System.out.println("wait 1");

                    synchronized (locker) {
                        locker.wait();

                    }
                    System.out.println("wait 2");

                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }



        });
        t1.start();
        Thread.sleep(1000);

        Thread t2 = new Thread(() -> {
            synchronized (locker){
                System.out.println("notify 1");
                locker.notify();
                System.out.println("notify 2");
            }
        });

        t2.start();
    }
}
